package com.drpclub.gamebackend.repository;

import com.drpclub.gamebackend.dao.UserDao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * @author dongruipeng
 * @Descrpition
 * @date 2019year 12month04day  11:24:45
 */
public interface UserRepository extends JpaRepository<UserDao, String> {

    int countByUsername(String userName);

    UserDao findAllByUsernameAndPassword(String username, String password);

    UserDao findAllByUsername(String username);

    @Modifying
    @Query(value = "update UserDao user set user.nickname = :nickname where user.username = :username")
    int updateNicknameByUsername(@Param("username") String username, @Param("nickname") String nickname);
}